<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>私有属性</title>
</head>

<body>
    <script>
        class Person {
            //公有属性
            name;
            //私有属性
            #age;
            //私有属性
            #weight;
            constructor(name, age, weigth) {
                this.name = name;
                this.#age = age;
                this.#weight = weigth;
            }
            info(){
                console.log(this.name);
                console.log(this.#age);
                console.log(this.#weight);

            }
        }

        //实例化
        const girl = new Person('a', 18, '45kg');
        console.log(girl);
        console.log(girl.name);
        
        girl.info()

    </script>
</body>

</html>